//
// Created by 86156 on 25-7-5.
//

#include "motor_driver.h"

#include "control_driver.h"
#include "pid_driver.h"
#include "tim.h"

Motor_t Motor1,Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8;

void Motor_Init()
{

    Motor1.PIN.PWM_htim = Motor1_PWM_HTIMx;
    Motor1.PIN.PWM_Channel = Motor1_PWM_CHANNELx;
    __HAL_TIM_SET_COMPARE(Motor1.PIN.PWM_htim,Motor1.PIN.PWM_Channel,MINTHROTTLE);
    HAL_TIM_PWM_Start(Motor1.PIN.PWM_htim, Motor1.PIN.PWM_Channel);

    Motor2.PIN.PWM_htim = Motor2_PWM_HTIMx;
    Motor2.PIN.PWM_Channel = Motor2_PWM_CHANNELx;
    __HAL_TIM_SET_COMPARE(Motor2.PIN.PWM_htim,Motor2.PIN.PWM_Channel,MINTHROTTLE);
    HAL_TIM_PWM_Start(Motor2.PIN.PWM_htim, Motor2.PIN.PWM_Channel);

    Motor3.PIN.PWM_htim = Motor3_PWM_HTIMx;
    Motor3.PIN.PWM_Channel = Motor3_PWM_CHANNELx;
    HAL_TIM_PWM_Start(Motor3.PIN.PWM_htim, Motor3.PIN.PWM_Channel);
    __HAL_TIM_SET_COMPARE(Motor3.PIN.PWM_htim,Motor3.PIN.PWM_Channel,MINTHROTTLE);


    Motor4.PIN.PWM_htim = Motor4_PWM_HTIMx;
    Motor4.PIN.PWM_Channel = Motor4_PWM_CHANNELx;
    HAL_TIM_PWM_Start(Motor4.PIN.PWM_htim, Motor4.PIN.PWM_Channel);
    __HAL_TIM_SET_COMPARE(Motor4.PIN.PWM_htim,Motor4.PIN.PWM_Channel,MINTHROTTLE);


    Motor5.PIN.PWM_htim = Motor5_PWM_HTIMx;
    Motor5.PIN.PWM_Channel = Motor5_PWM_CHANNELx;
    __HAL_TIM_SET_COMPARE(Motor5.PIN.PWM_htim,Motor5.PIN.PWM_Channel,MINTHROTTLE);
    HAL_TIM_PWM_Start(Motor5.PIN.PWM_htim, Motor5.PIN.PWM_Channel);

    Motor6.PIN.PWM_htim = Motor6_PWM_HTIMx;
    Motor6.PIN.PWM_Channel = Motor6_PWM_CHANNELx;
    __HAL_TIM_SET_COMPARE(Motor6.PIN.PWM_htim,Motor6.PIN.PWM_Channel,MINTHROTTLE);
    HAL_TIM_PWM_Start(Motor6.PIN.PWM_htim, Motor6.PIN.PWM_Channel);

    Motor7.PIN.PWM_htim = Motor7_PWM_HTIMx;
    Motor7.PIN.PWM_Channel = Motor7_PWM_CHANNELx;
    __HAL_TIM_SET_COMPARE(Motor7.PIN.PWM_htim,Motor7.PIN.PWM_Channel,MINTHROTTLE);
    HAL_TIM_PWM_Start(Motor7.PIN.PWM_htim, Motor7.PIN.PWM_Channel);

    Motor8.PIN.PWM_htim = Motor8_PWM_HTIMx;
    Motor8.PIN.PWM_Channel = Motor8_PWM_CHANNELx;
    __HAL_TIM_SET_COMPARE(Motor8.PIN.PWM_htim,Motor8.PIN.PWM_Channel,MINTHROTTLE);
    HAL_TIM_PWM_Start(Motor8.PIN.PWM_htim, Motor8.PIN.PWM_Channel);

}







